class Car:
    def drive(self):
        raise NotImplementedError("Subclass must implement abstract method")


class SportsCar(Car):
    def drive(self):
        return 'SportsCar driving!'


class Truck(Car):
    def drive(self):
        return 'Truck driving!'


class SimpleFactory:
    @staticmethod
    def build_car(type):
        if type == 'SportsCar':
            return SportsCar()
        elif type == 'Truck':
            return Truck()
        else:
            assert 0, 'Could not find car type ' + type


# 客户端代码
car = SimpleFactory.build_car('SportsCar')
print(car.drive())
